id="${id}"#if>>
@@ -691,7 +697,7 @@
<#if confirmation?has_content> onclick="return confirm('${confirmation?js_string}')"#if>>
<#if imgSrc?has_content>

#if>${description}
#macro>
-<#macro makeHyperlinkString hiddenFormName imgSrc title alternate linkUrl description linkStyle="" event="" action="" targetParameters="" targetWindow="" confirmation="" uniqueItemName="" height="" width="" id="">
+<#macro makeHyperlinkString dataBind hiddenFormName imgSrc title alternate linkUrl description linkStyle="" event="" action="" targetParameters="" targetWindow="" confirmation="" uniqueItemName="" height="" width="" id="">
<#if uniqueItemName?has_content>
<#local params = "{"presentation": "layer"">
<#if targetParameters?has_content>
@@ -708,6 +714,7 @@
data-dialog-height="${height}"
data-dialog-url="${linkUrl}"
<#if text?has_content>data-dialog-title="${text}"#if>
+ <#if dataBind?has_content> data-bind="${dataBind}"#if>
<#if linkStyle?has_content>class="${linkStyle}"#if>>
<#if description?has_content>${description}#if>
<#else>
@@ -716,6 +723,7 @@
<#if action?has_content && event?has_content> ${event}="${action}"#if>
<#if confirmation?has_content> data-confirm-message="${confirmation}"#if>
<#if id?has_content> id="${id}"#if>
+ <#if dataBind?has_content> data-bind="${dataBind}"#if>
<#if imgSrc?length == 0 && title?has_content> title="${title}"#if>>
<#if imgSrc?has_content>

#if>${description}
#if>
Index: applications/humanres/widget/forms/EmployeeForms.AddEmployee.js.ftl
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- applications/humanres/widget/forms/EmployeeForms.AddEmployee.js.ftl (date 1586446407013)
+++ applications/humanres/widget/forms/EmployeeForms.AddEmployee.js.ftl (date 1586446407013)
@@ -0,0 +1,22 @@
+
\ No newline at end of file
Index: framework/widget/src/main/java/org/apache/ofbiz/widget/model/ViewModelUtil.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- framework/widget/src/main/java/org/apache/ofbiz/widget/model/ViewModelUtil.java (date 1586445913498)
+++ framework/widget/src/main/java/org/apache/ofbiz/widget/model/ViewModelUtil.java (date 1586445913498)
@@ -0,0 +1,156 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *******************************************************************************/
+package org.apache.ofbiz.widget.model;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.ofbiz.base.lang.JSON;
+import org.apache.ofbiz.base.util.UtilGenerics;
+import org.apache.ofbiz.base.util.UtilValidate;
+
+public class ViewModelUtil {
+
+ public static final String requestAttributeViewModelForm = "ViewModelForm";
+ public static final String requestAttributeViewModelGrid = "ViewModelGrid";
+
+ public static String getModelMapForFormJs(HttpServletRequest request, String formName) {
+ Map
> modelViewMap = UtilGenerics.cast(request.getAttribute(requestAttributeViewModelForm));
+ if (modelViewMap!=null){
+ try {
+ return JSON.from(modelViewMap.get(formName)).toString();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ return "{}";
+ }
+
+ public static String getModelMapForGridJs(HttpServletRequest request, String formName) {
+ Map>> viewModelMap = UtilGenerics.cast(request.getAttribute(requestAttributeViewModelGrid));
+ if (viewModelMap!=null){
+ try {
+ return JSON.from(viewModelMap.get(formName)).toString();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ return "[]";
+ }
+
+ public static void addFieldListToModelMapForm(Map context, List formFieldList){
+ for(ModelFormField field : formFieldList){
+ addFieldToModelMapForm(context, field, false);
+ }
+ }
+
+ public static void addFieldToModelMapForm(Map context, ModelFormField currentFormField, boolean includeValue){
+ String value = "";
+ if (includeValue) {
+ getFieldValue(context,currentFormField);
+ }
+ String formName = currentFormField.getModelForm().getName();
+ HttpServletRequest request = (HttpServletRequest)context.get("request");
+ addToModelFieldForm(request, formName, currentFormField.getFieldName(), value);
+ }
+
+ private static void addToModelFieldForm(HttpServletRequest request, String formName, String fieldName, String value){
+ Map> modelViewMap = UtilGenerics.cast(request.getAttribute(ViewModelUtil.requestAttributeViewModelForm));
+ if (modelViewMap==null){
+ modelViewMap = new HashMap>();
+ request.setAttribute(ViewModelUtil.requestAttributeViewModelForm, modelViewMap);
+ }
+ Map formMap = modelViewMap.get(formName);
+ if (formMap==null){
+ formMap = new HashMap();
+ modelViewMap.put(formName, formMap);
+ }
+ formMap.put(fieldName,value);
+ }
+
+ public static boolean needDataBind(ModelForm currentForm){
+ if (UtilValidate.isEmpty(currentForm.getDataBind())){
+ return false;
+ }
+ return true;
+ }
+
+ public static void addFieldToModelMapGrid(Map context, ModelFormField currentFormField, int rowIndex){
+ String value = getFieldValue(context,currentFormField);
+ String formName = currentFormField.getModelForm().getName();
+ HttpServletRequest request = (HttpServletRequest)context.get("request");
+ addToModelMapGrid(request, formName, currentFormField.getFieldName(), value, rowIndex);
+ }
+
+ private static String getFieldValue(Map context, ModelFormField currentFormField){
+ int fieldType = currentFormField.getFieldInfo().getFieldType();
+ String value = "";
+ switch (fieldType){
+ case FieldInfo.TEXT: {
+ ModelFormField.TextField field = (ModelFormField.TextField)currentFormField.getFieldInfo();
+ value = currentFormField.getEntry(context, field.getDefaultValue(context));
+ break;
+ }
+ case FieldInfo.DATE_TIME: {
+ ModelFormField.DateTimeField field = (ModelFormField.DateTimeField)currentFormField.getFieldInfo();
+ value = currentFormField.getEntry(context, field.getDefaultValue(context));
+ }
+ break;
+ default:{
+ // FieldInfo.DISPLAY, FieldInfo.HYPERLINK, FieldInfo.DROP_DOWN, FieldInfo.DISPLAY_ENTITY
+ value = currentFormField.getEntry(context);
+ }
+ break;
+ }
+ return value;
+ }
+
+ private static void addToModelMapGrid(HttpServletRequest request, String formName, String fieldName, String value, int index){
+ Map>> modelViewMap = UtilGenerics.cast(request.getAttribute(requestAttributeViewModelGrid));
+ if (modelViewMap==null){
+ modelViewMap = new HashMap>>();
+ request.setAttribute(requestAttributeViewModelGrid, modelViewMap);
+ }
+ List